package cn.kenny.resource.mapper;

import cn.kenny.resource.pojo.Subject;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface SubjectMapper {

    @Select("select * from subject")
    public List<Subject> findAll();

    @Select("select distinct parent from subject")
    List<Integer> getParentList();

    @Select("select * from subject where level != 0 and parent = #{parent}")
    List<Subject> getSubjectByParent(Integer parent);

    @Select("select name from subject where level = 0 and parent = #{parent}")
    String getParent(Integer parent);
}